package com.hongdee.scm.warningreport.controller;

import com.hongdee.scm.warningreport.service.ITScmWarningReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 名  称:TScmWarningReportController
 * 类  型:class
 * 描  述:
 * 路  径:com.hongdee.scm.warningreport.controller
 * 作  者: 术洪超
 * 日  期:2017-06-22 16:12
 */
@RestController
@RequestMapping("/scm/warningReport")
public class TScmWarningReportController {

    @Autowired
    private ITScmWarningReportService itScmWarningReportService;

    @RequestMapping("/warningReport")
    @ResponseBody
    public Map warningReport(@RequestParam(name = "uid", defaultValue = "") String uid,
                             @RequestBody Map data) throws Exception {

        Map pageMap = itScmWarningReportService.warningReport(data, uid);
        pageMap.put("success", true);
        pageMap.put("msg", "预警查询成功！");
        return pageMap;

    }

    /**
     * @param uid  登录用户 ID
     * @param name 品牌、车系、车型名称
     * @return Map
     * @throws Exception
     * @desc 通过 JDBCDao分页查询
     * @author 术洪超
     */
    @RequestMapping("/warningPage")
    @ResponseBody
    public Map warningPage(@RequestParam(name = "uid", defaultValue = "") String uid,
                           @RequestParam(name = "start", defaultValue = "0") String start,
                           @RequestParam(name = "limit", defaultValue = "50") String limit,
                           @RequestParam(name = "name", defaultValue = "") String name,
                           @RequestParam(name = "type", defaultValue = "") String type,
                           @RequestBody Map data
    ) throws Exception {

        Map pageMap = itScmWarningReportService.warningPage(start, limit, name, uid, type, data);
        pageMap.put("success", true);
        pageMap.put("msg", "预警查询成功！");
        return pageMap;

    }

}
